<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>设定图像的混色模式</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.imageaffinematrixget.html">« imageaffinematrixget</a></li>
      <li style="float: right;"><a href="function.imageantialias.html">imageantialias »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.image.html">GD 和图像处理 函数</a></li>
    <li>设定图像的混色模式</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.imagealphablending" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">imagealphablending</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.6, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">imagealphablending</span> &mdash; <span class="dc-title">设定图像的混色模式</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.imagealphablending-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>imagealphablending</strong></span>(<span class="methodparam"><span class="type">resource</span> <code class="parameter">$image</code></span>, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$blendmode</code></span>): <span class="type">bool</span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>imagealphablending()</strong></span>
   允许在真彩色图像上使用两种不同的绘画模式。在混色（blending）模式下，alpha
   通道色彩成分提供给所有的绘画函数，例如 <span class="function"><a href="function.imagesetpixel.html" class="function">imagesetpixel()</a></span>
   决定底层的颜色应在何种程度上被允许照射透过。作为结果，GD
   自动将该点现有的颜色和画笔颜色混合，并将结果储存在图像中。结果的像素是不透明的。在非混色模式下，画笔颜色连同其
   alpha 通道信息一起被拷贝，替换掉目标像素。混色模式在画调色板图像时不可用。如果
   <code class="parameter">blendmode</code> 为 <strong><code>true</code></strong>，则启用混色模式，否则关闭。成功时返回 <strong><code>true</code></strong>， 或者在失败时返回 <strong><code>false</code></strong>。
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.imagealphablending-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    <dt>

<code class="parameter">image</code></dt>
<dd>
<p class="para">由图象创建函数(例如<span class="function"><a href="function.imagecreatetruecolor.html" class="function">imagecreatetruecolor()</a></span>)返回的 
<span class="classname"><a href="class.gdimage.html" class="classname">GdImage</a></span> 对象。</p></dd>

    
     <dt>
<code class="parameter">blendmode</code></dt>

     <dd>

      <p class="para">
       Whether to enable the blending mode or not. On true color images 
       the default value is <strong><code>true</code></strong> otherwise the default value is <strong><code>false</code></strong>
      </p>
     </dd>

    
   </dl>

  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.imagealphablending-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code>true</code></strong>， 或者在失败时返回 <strong><code>false</code></strong>。
  </p>
 </div>

 <div class="refsect1 examples" id="refsect1-function.imagealphablending-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-2626">
   <p><strong>示例 #1 <span class="function"><strong>imagealphablending()</strong></span> usage example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//&nbsp;Create&nbsp;image<br /></span><span style="color: #0000BB">$im&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">imagecreatetruecolor</span><span style="color: #007700">(</span><span style="color: #0000BB">100</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">100</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;Set&nbsp;alphablending&nbsp;to&nbsp;on<br /></span><span style="color: #0000BB">imagealphablending</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">true</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;Draw&nbsp;a&nbsp;square<br /></span><span style="color: #0000BB">imagefilledrectangle</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">30</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">30</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">70</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">70</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">imagecolorallocate</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">255</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">));<br /><br /></span><span style="color: #FF8000">//&nbsp;Output<br /></span><span style="color: #0000BB">header</span><span style="color: #007700">(</span><span style="color: #DD0000">'Content-type:&nbsp;image/png'</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">imagepng</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">imagedestroy</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

  </div>
 </div>

 <div class="refsect1 notes" id="refsect1-function.imagealphablending-notes">
  <h3 class="title">注释</h3>
 </div>

</div></div></div></body></html>